<template>
  <div class="audit-meeting-view" v-if="pageNum > 1 || meetingList.length">

    <item-title title="会议信息" />

    <meeting-view :datas="meetingList"></meeting-view>

    <pagination style="display:flex;justify-content:flex-end;" :total="total" :page.sync="pageNum"
                :limit.sync="pageSize" @pagination="getData" />

  </div>
</template>

<script>
    import meetingView from "../../../project/details/modules/meetingView";
    export default {
        name: "meetingListView",
        components:{meetingView},
        props:{
            // datas:{
            //     type:Object,
            //     default:function () {
            //         return{}
            //     }
            // },
            project:{
                type:Object,
                default:()=>{}
            },
            business:{
                type:String,
                default:''
            },
            task:{
                type:Object,
                default:()=>{}
            }
        },
        watch:{
            project:{
                handler(newV,oldV){
                    if (newV && newV.id){
                        this.getListData();
                    }
                },
                immediate:true,
                deep:true
            },
            task:{
                handler(newV,oldV){
                    if (newV && newV.id){
                        this.getTaskListData();
                    }
                },
                immediate:true,
                deep:true
            }
        },
        data(){
            return{
                pageSize:10,
                pageNum:1,
                total:0,
                meetingList:[],
            }
        },
        mounted(){
            console.log(this.project)
            // if (this.project.id){
            //     this.getListData();
            // }

        },
        methods:{
            getData:function(){
                if (this.project && this.project.id){
                    this.getListData()
                }else {
                    this.getTaskListData();
                }
            },
            getTaskListData:function(){
                let data = {
                    resolution_business:'TaskAcceptance',
                    key:'',
                    type:'',
                    meeting_type:'',
                    project_id:'',
                    task_id:this.task.id,
                    i_create:0,
                    creator_id:'',
                    value:[],
                    pager:{
                        limit:this.pageSize1,
                        skip:this.pageNum1,
                        OrderBy:'',
                        OrderMethod:-1
                    },
                };
                this.$api.PROJECT_START_MEETING_LIST(data).then(res=>{
                    if (res.code == 200){

                        this.meetingList = res.data.data || [];
                        this.total = res.data.total
                    }
                })
            },
            getListData:function () {
                let data = {
                    resolution_business:this.business,
                    meeting_type:"project",
                    relation_id:this.project.id,
                    pager:{
                        limit:this.pageSize,
                        skip:this.pageNum,
                        OrderBy:'',
                        OrderMethod:-1
                    }
                }
                this.$api.PROJECT_START_PROJECT_MEETING_LIST(data).then(res=>{
                    if (res.code == 200){
                        this.meetingList = res.data.data || [];
                        this.total = res.data.total
                    }
                })
            }
        }
    }
</script>

<style scoped>

</style>
